﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using AutoMapper;

namespace Data 
{
    public class TheLoaiRepository 
    {
        public List<TheLoaiDTO> SelectAllTheLoais()
        {
            List<TheLoaiDTO> list = new List<TheLoaiDTO>();
            QuanLyNhaSachEntities context = new QuanLyNhaSachEntities();

            var query = from tlItem in context.TheLoaiList 
                        select tlItem;
            foreach (THELOAI item in query)
            {
                TheLoaiDTO dto = new TheLoaiDTO();
                Mapper.CreateMap<THELOAI, TheLoaiDTO>();
                dto = Mapper.Map<THELOAI, TheLoaiDTO>(item);

                list.Add(dto);
            }
            return list;
        }
    }
}
